package com.scf.loanmanage.service.ServiceImp;

import com.scf.loanmanage.dao.AssetPreservationMapper;
import com.scf.loanmanage.entity.AssetPreservation;
import com.scf.loanmanage.service.AssetPreservationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class AssetPreservationImpl implements AssetPreservationService {

    @Resource
    AssetPreservationMapper assetPreservationMapper;



    @Override
    public List<AssetPreservation> selectAll(Integer pageIndex, Integer pageSize) {
        return assetPreservationMapper.selectAll(pageIndex, pageSize);
    }

    @Override
    public List<AssetPreservation> selectAlls() {
        return assetPreservationMapper.selectAlls();
}

    @Override
    public void insert(Integer asid, String enterprisename, String code, Double amountborrowed, String salesman, String registrant, Integer overterm, Integer overdate, Date begindate) {
        List<AssetPreservation> assetPreservations = assetPreservationMapper.selectAlls();

        for (AssetPreservation assetPreservation:assetPreservations){
            if( assetPreservation.getEnterprisename().equals(enterprisename)){
                return;
            }

        }
        assetPreservationMapper.insert(asid, enterprisename, code, amountborrowed, salesman, registrant, overterm, overdate, begindate);
    }

    @Override
    public Integer selectcount() {
        return assetPreservationMapper.selectcount();
    }

    @Override
    public List<AssetPreservation> selectByname(String enterprisename, String code) {
        return assetPreservationMapper.selectByname(enterprisename, code);
    }

    @Override
    public void upadte(Integer oid, Integer count) {
        assetPreservationMapper.upadte(oid, count);
    }

    @Override
    public AssetPreservation selctByid(Integer oid) {


        return assetPreservationMapper.selctByid(oid);
    }

    @Override
    public void updateBynames(String registrant, Integer asid) {
        assetPreservationMapper.updateBynames(registrant, asid);
    }
}
